// module.exports = () => {
//     return async (ctx,next) => {
//         //1.排除booklist接口的校验
//         let writePath = ['/booklist'];
//         if(writePath.includes(ctx.path)){
//             await next();
//         }else{
//             //2.校验  获取前端headers传递的egg-identity
//             let indentity = ctx.get('egg-identity');
            
//             if(indentity && indentity === 'admin'){
//                 await next();
//             }else{
//                 ctx.body = {
//                     msg:"无权限", 
//                     status:401,
//                     code:0
//                 }
//             }
//         }
//     }
// }

module.exports = () => {
    return async (ctx,next) => {
        //1.排除booklist接口的校验
        let writePath = ['/api/list'];
        if(ctx.method === 'GET' && writePath.includes(ctx.path)){
            await next();
        }else{
            //2.校验  获取前端headers传递的egg-identity
            let indentity = ctx.get('egg-identity');
            
            if(indentity && indentity === 'admin'){
                await next();
            }else{
                ctx.body = {
                    msg:"无权限", 
                    status:401,
                    code:0
                }
            }
        }
    }
}